use std::marker::PhantomData;

// 幻像类型元组， 元组中包含两个类型，第一个类型为A，第二个类型为PhantomData<B>
#[derive(PartialEq)]
struct PhantomTuple<A, B>(A, PhantomData<B>);

#[derive(PartialEq)]
struct PhantomStruct<A, B> {
    first : A,
    phantom: PhantomData<B>,
}

fn main() {

    let _tuple1: PhantomTuple<char, f32> = PhantomTuple('Q', PhantomData);

    let _tuple2: PhantomTuple<char, i32> = PhantomTuple('Q', PhantomData);

    let _struct1: PhantomStruct<char, f32> = PhantomStruct {
        first: 'Q',
        phantom: PhantomData,
    };
    let _struct2: PhantomStruct<char, i64> = PhantomStruct {
        first: 'Q',
        phantom: PhantomData,
    };

    // compile error ,type mismatch so error
    println!("_tuple1 == _tuple2 yields: {}", _tuple1 == _tuple2);

    // compile error ,type mismatch so error
    println!("_struct1 == _struct2 yields: {}", _struct1 == _struct2);
}